﻿using System;
using System.Collections.Generic;

namespace Terraria.ModLoader
{
	// Token: 0x02000232 RID: 562
	public abstract class DrawLayer<InfoType>
	{
		// Token: 0x060017F1 RID: 6129 RVA: 0x00011C7A File Offset: 0x0000FE7A
		protected DrawLayer(string mod, string name, Action<InfoType> layer)
		{
			this.mod = mod;
			this.Name = name;
			this.parent = null;
			this.layer = layer;
		}

		// Token: 0x060017F2 RID: 6130 RVA: 0x00011CA5 File Offset: 0x0000FEA5
		protected DrawLayer(string mod, string name, DrawLayer<InfoType> parent, Action<InfoType> layer)
		{
			this.mod = mod;
			this.Name = name;
			this.parent = parent;
			this.layer = layer;
		}

		// Token: 0x060017F3 RID: 6131 RVA: 0x0041B90C File Offset: 0x00419B0C
		public bool ShouldDraw<T>(IList<T> layers) where T : DrawLayer<InfoType>
		{
			if (!this.visible)
			{
				return false;
			}
			for (DrawLayer<InfoType> drawLayer = this.parent; drawLayer != null; drawLayer = drawLayer.parent)
			{
				if (!drawLayer.visible || !layers.Contains((T)((object)drawLayer)))
				{
					return false;
				}
			}
			return true;
		}

		// Token: 0x060017F4 RID: 6132 RVA: 0x00011CD1 File Offset: 0x0000FED1
		public virtual void Draw(ref InfoType drawInfo)
		{
			this.layer(drawInfo);
		}

		// Token: 0x0400164B RID: 5707
		public readonly string mod;

		// Token: 0x0400164C RID: 5708
		public readonly string Name;

		// Token: 0x0400164D RID: 5709
		public readonly DrawLayer<InfoType> parent;

		// Token: 0x0400164E RID: 5710
		public readonly Action<InfoType> layer;

		// Token: 0x0400164F RID: 5711
		public bool visible = true;
	}
}
